﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Ajax.Utilities;
using Model;

public partial class Lysingar : System.Web.UI.Page
{
    DataClassesDataContext data = new DataClassesDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        PopulateSite();
    }

    //public void PopulateRepeter()
    //{
    //    var db = new DataClassesDataContext();

    //    var qry = (from x in db.JobOffers
    //        join c in db.JobStatus on x.JobStatus equals c.StatusId
    //               where c.StatusName.Equals("Aktiv")
    //        select x).ToList();
    //    rptJobOffers.DataSource = qry;
    //    rptJobOffers.DataBind();cvb   væ lhækr,bm nvmx mc,
    //}

    public void PopulateSite()
    {
        if (Request.QueryString["Id"] != null)
        {
            var qry = from x in data.JobOffers
                      where x.JobId == Convert.ToInt32(Request.QueryString["Id"])
                      select x;
            foreach (var q in qry)
            {
                ltJobId.Text = q.JobId.ToString();
                ltTitle.Text = q.JobTitle;
                ltCompany.Text = q.Company.CompanyName;
                ltStart.Text = ShortDateString(q.JobCreated.ToString());
                ltEnd.Text = ShortDateString(q.JobExpire.ToString());
                ltStatus.Text = q.JobStatus1.StatusName;
                ltCategory.Text = q.JobCategory1.JobCategoryName;
                ltJobLength.Text = q.JobLength1.JobLengthText;
                ltContent.Text = q.JobContent;

            }


        }
    }
    public static string ShortDateString(string date)
    {
        if (date.Length > 9)
        {
            date = date.Substring(0, 9);
        }
        return date;
    }
}